Make KeywordArgs fail if unexpected keys are passed in#187
Merged
alex-fedorov merged 1 commit intoegonSchiele:masterfrom Jul 23, 2015
Merged
Conversation
Contributor
Author
|
Hmm weird, specs passed with 2.2 on my machine. I'll look into the failures. |
Contributor
Author
|
Ah |
61f67c9 to
31e2066
Compare
Collaborator
|
Looks like you actually want to fix this spec. Because it tries to pass in unexpected argument and expects it to not fail. Seems like a buggy behavior to me. |
Contributor
Author
|
Okay I think I fixed it - let me know if I violated the intent of the spec or whatnot |
lib/contracts/builtin_contracts.rb
Outdated
Collaborator
There was a problem hiding this comment.
Can you use guard statement here instead - current code makes it hard to read. Example:
def valid?(hash)
return false unless hash.keys - options.keys == [] # <--- this is a guard statement
# .. do the main job here ..
end
Contributor
Author
There was a problem hiding this comment.
Oh yeah for sure, should've asked about that
Collaborator
|
Other than that, looks good. |
31e2066 to
1960743
Compare
Collaborator
|
@abevoelker Thanks! |
alex-fedorov
added a commit
that referenced
this pull request
Jul 23, 2015
Make KeywordArgs fail if unexpected keys are passed in
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Wasn't sure where to put the KeywordArgs specs - let me know if it should go in spec/contracts_spec.rb or whatnot (or if I'm otherwise way off base)